package com.chb.friend;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.KeyValueTextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class RunJob {
	public static void main(String[] args) throws Exception{
		System.setProperty("HADOOP_USER_NAME", "chb");
		Configuration conf = new Configuration();
		FileSystem fs = FileSystem.get(conf);
		Job job = Job.getInstance();
		job.setJobName("Fof");
		job.setJarByClass(RunJob.class);
		//Mapper
		job.setMapperClass(FofMapper.class);
		job.setMapOutputKeyClass(Fof.class);
		job.setMapOutputValueClass(IntWritable.class);
		job.setJar("C:\\Users\\12285\\Desktop\\Fof.jar");
		//Reducer
		job.setReducerClass(FofReducer.class);
		job.setInputFormatClass(KeyValueTextInputFormat.class);
		//输入
		FileInputFormat.addInputPaths(job, "/user/chb/input/friend");
		//输出
		Path out = new Path("/user/chb/output/fof1");
		if (fs.exists(out)) {
			fs.delete(out, true);
		}
		FileOutputFormat.setOutputPath(job, out);
		boolean f = job.waitForCompletion(true);
		if (f) {
			System.out.println("任务完成。。。");
		}

	}
}
